# encoding: utf-8
"""
@author: 夏洛
@QQ: 1972386194
@file: 红星.py
"""

'''
com.cdsb.newsreader
脱壳
frida-dexdump -U -f com.cdsb.newsreader
hook
frida -UF -l aaa.js | tee hook.log

fd1860843f654dba156a9d5f17e40ced
070de70ea03fd52306e87075bd121134  1655271393495

{"Model":"Pixel 3","Brand":"google","OS":"Android 9","OSDetail":"9","Udid":"4c5ed759-5af7-4870-b599-313dfcf27148","Token":"0","Timestamp":"1655274679801","UserId":-1,"Secret":"ZDQ0OGRkOGJlMGYwZDhlYWQ4MGQ3ZDNkNTFjY2JmMzc\u003d","Version":"V6.9.4","VersionCode":"2020071401","JPushRegId":"18071adc03f76a60fc7"}
'''

import requests,hashlib,time,base64

def md5_test(str):
    # 创建md5对象
    hl = hashlib.md5()
    # Tips
    sss = "4c5ed759-5af7-4870-b599-313dfcf27148app@cdsb!^jlx%2386*hip${}".format(str)
    # 此处必须声明encode
    # 若写法为hl.update(str) 报错为： Unicode-objects must be encoded before hashing
    hl.update(sss.encode(encoding='utf-8'))
    print( hl.hexdigest())
    return hl.hexdigest()
#d448dd8be0f0d8ead80d7d3d51ccbf37
# md5_test(1655274679801)


def get_data():
    mmm = {"Model":"Pixel 3","Brand":"google","OS":"Android 9","OSDetail":"9","Udid":"4c5ed759-5af7-4870-b599-313dfcf27148","Token":"0","Timestamp":"{}","UserId":-1,"Secret":"{}","Version":"V6.9.4","VersionCode":"2020071401","JPushRegId":"18071adc03f76a60fc7"}
    import json
    timss = int(time.time()* 1000)
    Secret =base64.b64encode(md5_test(timss).encode('utf-8')).decode()
    print(Secret)
    mmm['Timestamp'] = str(timss)
    mmm['Secret'] = Secret
    mm = json.dumps(mmm)
    headers = {
        "DeviceInfo": mm,
        "Content-Type": "application/json; charset=UTF-8",
        "Content-Length": "35",
        "Host": "app.cdsb.com",
        "Connection": "Keep-Alive",
        "Accept-Encoding": "gzip",
        "Cookie": "acw_tc=2f61f26b16552698249592183e5faed146d982649d15fad3da6d4144a24ed6",
        "User-Agent": "okhttp/3.12.0"
    }
    session = requests.session()
    params = {
        "cId": 1,
        "timestamp": 0,
        "pageNum": 1
    }

    url = 'https://app.cdsb.com/cdsb_app/api3/GetICListData'
    session.headers = headers
    res = session.post(url,json=params)
    print(res.text)
get_data()



